package com.blackcet.wholeexecption.execption;

import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * <p> 描述 ：理自定义的业务异常
 * @author : blackcat
 * @date : 2021/2/23 11:16
 */
@Data
@NoArgsConstructor
public class BlackcatException extends RuntimeException{
    private static final long serialVersionUID = 1L;

    /**
     * 错误码
     */
    protected String errorCode;
    /**
     * 错误信息
     */
    protected String errorMsg;

    public BlackcatException(BaseCodeInfo code) {
        super(code.code());
        this.errorCode = code.code();
        this.errorMsg = code.message();
    }

    public BlackcatException(BaseCodeInfo code, Throwable cause) {
        super(code.code(), cause);
        this.errorCode = code.code();
        this.errorMsg = code.message();
    }

    public BlackcatException(String errorMsg) {
        super(errorMsg);
        this.errorMsg = errorMsg;
    }

    public BlackcatException(String errorCode, String errorMsg) {
        super(errorCode);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public BlackcatException(String errorCode, String errorMsg, Throwable cause) {
        super(errorCode, cause);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    @Override
    public Throwable fillInStackTrace() {
        return this;
    }
}
